using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class vPurchaseOrderMap : EntityTypeConfiguration<vPurchaseOrder>
    {
        public vPurchaseOrderMap()
        {
            // Primary Key
            this.HasKey(t => new { t.NUMBER, t.DATE, t.Closed, t.Item_Cost, t.Item_Qty, t.Item, t.Type, t.Category, t.TypeId, t.CategId, t.Currency_Symbol });

            // Properties
            this.Property(t => t.NUMBER)
                .IsRequired()
                .HasMaxLength(7);

            this.Property(t => t.Currency)
                .HasMaxLength(20);

            this.Property(t => t.Item)
                .IsRequired()
                .HasMaxLength(10);

            this.Property(t => t.Type)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.Category)
                .IsRequired()
                .HasMaxLength(100);

            this.Property(t => t.TypeId)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.CategId)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.Vendor)
                .HasMaxLength(50);

            this.Property(t => t.Customv2)
                .HasMaxLength(30);

            this.Property(t => t.Customv3)
                .HasMaxLength(30);

            this.Property(t => t.SeasonName)
                .HasMaxLength(50);

            this.Property(t => t.Customv4)
                .HasMaxLength(30);

            this.Property(t => t.Customv5)
                .HasMaxLength(30);

            this.Property(t => t.Usage)
                .HasMaxLength(30);

            this.Property(t => t.ModeOfShip)
                .HasMaxLength(30);

            this.Property(t => t.ABCClassif)
                .HasMaxLength(2);

            this.Property(t => t.XYZClassif)
                .HasMaxLength(2);

            this.Property(t => t.vendSrh)
                .HasMaxLength(6);

            this.Property(t => t.Currency_Symbol)
                .IsRequired()
                .HasMaxLength(5);

            this.Property(t => t.Vendor_Address1)
                .HasMaxLength(35);

            this.Property(t => t.Vendor_Address2)
                .HasMaxLength(35);

            this.Property(t => t.Vendor_Phone)
                .HasMaxLength(40);

            // Table & Column Mappings
            this.ToTable("vPurchaseOrders");
            this.Property(t => t.NUMBER).HasColumnName("NUMBER");
            this.Property(t => t.DATE).HasColumnName("DATE");
            this.Property(t => t.Invoice_Total).HasColumnName("Invoice Total");
            this.Property(t => t.Closed).HasColumnName("Closed");
            this.Property(t => t.COMMENTS).HasColumnName("COMMENTS");
            this.Property(t => t.Item_Cost).HasColumnName("Item Cost");
            this.Property(t => t.Line_Total).HasColumnName("Line Total");
            this.Property(t => t.Item_Qty).HasColumnName("Item Qty");
            this.Property(t => t.Currency).HasColumnName("Currency");
            this.Property(t => t.Item).HasColumnName("Item");
            this.Property(t => t.Type).HasColumnName("Type");
            this.Property(t => t.Category).HasColumnName("Category");
            this.Property(t => t.TypeId).HasColumnName("TypeId");
            this.Property(t => t.CategId).HasColumnName("CategId");
            this.Property(t => t.Vendor).HasColumnName("Vendor");
            this.Property(t => t.Customv1).HasColumnName("Customv1");
            this.Property(t => t.Customv2).HasColumnName("Customv2");
            this.Property(t => t.Customv3).HasColumnName("Customv3");
            this.Property(t => t.SeasonName).HasColumnName("SeasonName");
            this.Property(t => t.Customv4).HasColumnName("Customv4");
            this.Property(t => t.Customv5).HasColumnName("Customv5");
            this.Property(t => t.Country).HasColumnName("Country");
            this.Property(t => t.BU).HasColumnName("BU");
            this.Property(t => t.Cluster).HasColumnName("Cluster");
            this.Property(t => t.ProductLine).HasColumnName("ProductLine");
            this.Property(t => t.ItemKind).HasColumnName("ItemKind");
            this.Property(t => t.Program).HasColumnName("Program");
            this.Property(t => t.Group_Number).HasColumnName("Group Number");
            this.Property(t => t.GrpNumId).HasColumnName("GrpNumId");
            this.Property(t => t.Subgroup).HasColumnName("Subgroup");
            this.Property(t => t.Family).HasColumnName("Family");
            this.Property(t => t.Usage).HasColumnName("Usage");
            this.Property(t => t.Class).HasColumnName("Class");
            this.Property(t => t.ModeOfShip).HasColumnName("ModeOfShip");
            this.Property(t => t.ABCClassif).HasColumnName("ABCClassif");
            this.Property(t => t.XYZClassif).HasColumnName("XYZClassif");
            this.Property(t => t.vendSrh).HasColumnName("vendSrh");
            this.Property(t => t.ExpiryDateEnabled).HasColumnName("ExpiryDateEnabled");
            this.Property(t => t.Currency_Symbol).HasColumnName("Currency Symbol");
            this.Property(t => t.Vendor_Address1).HasColumnName("Vendor Address1");
            this.Property(t => t.Vendor_Address2).HasColumnName("Vendor Address2");
            this.Property(t => t.Vendor_Phone).HasColumnName("Vendor Phone");
            this.Property(t => t.Payment_Terms).HasColumnName("Payment Terms");
        }
    }
}
